package com.itheima_02;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolExectorsTest1 {

    public static void main(String[] args) {
        ThreadPoolExecutor pool = new ThreadPoolExecutor(
                1,
                2,
                3,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue(10),
                Executors.defaultThreadFactory(),
                //new ThreadPoolExecutor.AbortPolicy()
                //new ThreadPoolExecutor.CallerRunsPolicy()
                new ThreadPoolExecutor.DiscardOldestPolicy()
               // new ThreadPoolExecutor.DiscardPolicy()

        );
        /*pool.submit(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 17; i++) {
                    System.out.println(Thread.currentThread().getName()+"执行了");
                }
            }
        });*/
        for (int i=0;i<3;i++) {
            pool.submit(new Runnable() {
                @Override
                public void run() {
                   //
                        System.out.println(Thread.currentThread().getName()+"执行了");
                   // }
                }
            });
        }


        pool.shutdown();
    }
}
